<?php

use Faker\Factory as Faker;
use App\Models\ChannelOrderRead;
use App\Repositories\ChannelOrderReadRepository;

trait MakeChannelOrderReadTrait
{
    /**
     * Create fake instance of ChannelOrderRead and save it in database
     *
     * @param array $channelOrderReadFields
     * @return ChannelOrderRead
     */
    public function makeChannelOrderRead($channelOrderReadFields = [])
    {
        /** @var ChannelOrderReadRepository $channelOrderReadRepo */
        $channelOrderReadRepo = App::make(ChannelOrderReadRepository::class);
        $theme = $this->fakeChannelOrderReadData($channelOrderReadFields);
        return $channelOrderReadRepo->create($theme);
    }

    /**
     * Get fake instance of ChannelOrderRead
     *
     * @param array $channelOrderReadFields
     * @return ChannelOrderRead
     */
    public function fakeChannelOrderRead($channelOrderReadFields = [])
    {
        return new ChannelOrderRead($this->fakeChannelOrderReadData($channelOrderReadFields));
    }

    /**
     * Get fake data of ChannelOrderRead
     *
     * @param array $postFields
     * @return array
     */
    public function fakeChannelOrderReadData($channelOrderReadFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'channel_id' => $fake->randomDigitNotNull,
            'channel_order_id' => $fake->randomDigitNotNull,
            'wechat_user_id' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $channelOrderReadFields);
    }
}
